package com.dji.sample.manage.controller;

import com.dji.sample.manage.model.receiver.DevicePositionReceiver;
import com.dji.sample.manage.model.receiver.PositionItemReceiver;
import com.dji.sample.manage.service.DevicePositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yjt
 * @date 2022-10-25
 * @description:
 */
@RestController
public class DevicePositionController {

    @Autowired
    DevicePositionService devicePositionService;

    @RequestMapping("save")
    public String save(){
        String[] sns={"1581F5BKD225L00BWR0S","1ZMBJB600300KP","1ZNBJBF00C003M","1581F5FJD228K00A0323","07JDE56002008ZAPP","4GCCJ2RR0A00AY"};
        for (String sn : sns) {
            DevicePositionReceiver devicePositionReceiver = new DevicePositionReceiver();
            devicePositionReceiver.setData("1");
            devicePositionReceiver.setPositionItemReceiver(new PositionItemReceiver("0","0","0"));
            devicePositionReceiver.setDeviceSn(sn);
            devicePositionReceiver.setTid("aaa");
            devicePositionReceiver.setBid("bbbb");
            devicePositionReceiver.setTimestamp(System.currentTimeMillis());
            devicePositionService.save(devicePositionReceiver);
        }
        return "success";
    }

    @RequestMapping("query")
    public String query(){
        String[] sns={"1581F5BKD225L00BWR0S"};
        for (String sn : sns) {
            System.out.println( devicePositionService.selectDevicePosition(sn,"2022-10-10"));
        }
        return "success";
    }

}
